using System;
using System.Collections.Generic;
using System.Text;

namespace Weazel.Toad.Application.Actions
{
  public class SelectNextOpenItemAction
    : ActionBase
  {
    public override void Execute(object sender, EventArgs e)
    {
      if (Application.Instance.OpenItems.Count > 0)
      {
        int index =
          Application.Instance.OpenItems.IndexOf(Application.Instance.SelectedItem);

        index++;

        if (index == Application.Instance.OpenItems.Count)
          index = 0;

        Application.Instance.SelectedItem = Application.Instance.OpenItems[index];
      }
    }
  }
}
